package com.csmz.web.controller.enterprise;

import com.csmz.common.annotation.Log;
import com.csmz.common.core.controller.BaseController;
import com.csmz.common.core.domain.AjaxResult;
import com.csmz.common.core.page.TableDataInfo;
import com.csmz.common.enums.BusinessType;
import com.csmz.common.utils.poi.ExcelUtil;
import com.csmz.enterprise.domain.CsmzHbhPeopleList;
import com.csmz.enterprise.service.ICsmzHbhPeopleListService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 黑白灰名单Controller
 * 
 * @author TT
 * @date 2025-09-22
 */
@RestController
@RequestMapping("/enterprise/hbhList")
public class CsmzHbhPeopleListController extends BaseController
{
    @Autowired
    private ICsmzHbhPeopleListService csmzHbhPeopleListService;

    /**
     * 查询黑白灰名单列表
     */
    @PreAuthorize("@ss.hasPermi('enterprise:hbhList:list')")
    @GetMapping("/list")
    public TableDataInfo list(CsmzHbhPeopleList csmzHbhPeopleList)
    {
        startPage();
        List<CsmzHbhPeopleList> list = csmzHbhPeopleListService.selectCsmzHbhPeopleListList(csmzHbhPeopleList);
        return getDataTable(list);
    }

    /**
     * 导出黑白灰名单列表
     */
    @PreAuthorize("@ss.hasPermi('enterprise:hbhList:export')")
    @Log(title = "黑白灰名单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CsmzHbhPeopleList csmzHbhPeopleList)
    {
        List<CsmzHbhPeopleList> list = csmzHbhPeopleListService.selectCsmzHbhPeopleListList(csmzHbhPeopleList);
        ExcelUtil<CsmzHbhPeopleList> util = new ExcelUtil<CsmzHbhPeopleList>(CsmzHbhPeopleList.class);
        util.exportExcel(response, list, "黑白灰名单数据");
    }

    /**
     * 获取黑白灰名单详细信息
     */
    @PreAuthorize("@ss.hasPermi('enterprise:hbhList:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(csmzHbhPeopleListService.selectCsmzHbhPeopleListById(id));
    }

    /**
     * 新增黑白灰名单
     */
    @PreAuthorize("@ss.hasPermi('enterprise:hbhList:add')")
    @Log(title = "黑白灰名单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CsmzHbhPeopleList csmzHbhPeopleList)
    {
        return toAjax(csmzHbhPeopleListService.insertCsmzHbhPeopleList(csmzHbhPeopleList));
    }

    /**
     * 修改黑白灰名单
     */
    @PreAuthorize("@ss.hasPermi('enterprise:hbhList:edit')")
    @Log(title = "黑白灰名单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CsmzHbhPeopleList csmzHbhPeopleList)
    {
        return toAjax(csmzHbhPeopleListService.updateCsmzHbhPeopleList(csmzHbhPeopleList));
    }

    /**
     * 删除黑白灰名单
     */
    @PreAuthorize("@ss.hasPermi('enterprise:hbhList:remove')")
    @Log(title = "黑白灰名单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(csmzHbhPeopleListService.deleteCsmzHbhPeopleListByIds(ids));
    }
}
